//
//  BodyTemperatureDataModel.swift
//  TimeBoat
//
//  Created by Jun on 2022/9/8.
//  Copyright © 2022 Time Boat. All rights reserved.
//

import Foundation

/// 体温
@objcMembers class BodyTemperatureDataModel: NSObject {
    /// 体温, 2 byte
    var bodyTempInt: UInt16 = 0
    var bodyTempStr: String = ""
    
    private let DATA_LEN = 2
    
    convenience init(buf: [UInt8]) {
        self.init()
        
        if (buf.count >= DATA_LEN) {
            let temp = UInt16.toUInt16(buf: buf, offset: 0)
            bodyTempInt = temp
            bodyTempStr = String().appendingFormat("%.2f", Float(Float(temp) / 10.0))
        }
    }
    
    @objc func toString() -> String {
        var str = self.yy_modelToJSONString()
        if nil == str {
            str = ""
        }
        
        return str!
    }
}

